/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class DAOAdmin extends BaseDAO {

    private Connection con = getConnection();
    private ResultSet rs = null;

    public ResultSet selectSuject2() {
        try {
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT * FROM SUBJECT");

        } catch (SQLException ex) {
            Logger.getLogger(DAOMenu.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }

    public ResultSet selectSuject3() {
        try {
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT * FROM subSubject");

        } catch (SQLException ex) {
            Logger.getLogger(DAOMenu.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }

    public ResultSet selectQuestion() {
        try {
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT * FROM Questions");

        } catch (SQLException ex) {
            Logger.getLogger(DAOMenu.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }

    public ResultSet selectQuestion2(int id) {
        try {
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT * FROM Questions where subID = " + id);

        } catch (SQLException ex) {
            Logger.getLogger(DAOMenu.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }

    public ResultSet selectSubject(int id) {
        try {
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT * FROM Subject where subjectID = " + id);

        } catch (SQLException ex) {
            Logger.getLogger(DAOMenu.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }

    public ResultSet selectSubSubject(int id) {
        try {
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT * FROM subSubject where SubID = " + id);

        } catch (SQLException ex) {
            Logger.getLogger(DAOMenu.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }
    public ResultSet selectSubSubjectID(int id) {
        try {
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT * FROM subSubject where SubjectID = " + id);

        } catch (SQLException ex) {
            Logger.getLogger(DAOMenu.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }
    public ResultSet selectAnswer(int id) {
        try {
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT Count(*) AS Tong FROM Answers where QuestionID  = " + id);

        } catch (SQLException ex) {
            Logger.getLogger(DAOMenu.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }
    public ResultSet selectAnswer2(int id) {
        try {
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT * FROM Answers where QuestionID  = " + id);

        } catch (SQLException ex) {
            Logger.getLogger(DAOMenu.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }
    public ResultSet selectTest() {
        try {
            Statement stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT * FROM Test");

        } catch (SQLException ex) {
            Logger.getLogger(DAOMenu.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;
    }
}
